package co.fitstart.weapp.api.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.credit.Credit;
import co.fitstart.entity.credit.CreditTransaction;
import co.fitstart.entity.user.User;

/**
 * 
 * @author dan
 *
 */
@Dao("hibernate")
public interface CreditDao {
    
    /**
     * 
     * @param user
     * @return
     */
    @Query("FROM Credit WHERE user = :user")
    public Credit load(@Variable("user") User user);
    
    /**
     * 
     * @param credit
     * @return
     */
    @Query("FROM CreditTransaction creditTransaction WHERE creditTransaction.credit = :credit ORDER BY creditTransaction.createTime DESC")
    public List<CreditTransaction> listCreditTransaction(@Variable("credit") Credit credit);

}
